package leetCode.q94;


import java.util.ArrayList;
import java.util.List;

public class Me {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public List<Integer> inorderTraversal(TreeNode root) {
        ArrayList<Integer> res = new ArrayList<>();
        x(root, res);
        return res;
    }

    public static void x(TreeNode root, List<Integer> res) {
        if(root == null) return;

        if(root.left!=null) x(root.left,res);
        res.add(new Integer(root.val));
        if(root.right!=null) x(root.right,res);
    }
}
